# Maintainer: Balló György <ballogyor+arch at gmail dot com>
# Contributor: Joey Dumont <joey.dumont@gmail.com>
# Contributor: Giuseppe Borzi <gborzi@ieee.org>
# Contributor: Stefan Paquay <stefanpaquay@gmail.com>

pkgname=superlu
pkgver=5.3.0
pkgrel=1
pkgdesc='Set of subroutines to solve a sparse linear system'
arch=('loong64' 'x86_64')
url='https://github.com/xiaoyeli/superlu/'
license=('BSD')
depends=('blas')
makedepends=('cmake' 'gcc-fortran' 'ninja')
source=("https://github.com/xiaoyeli/$pkgname/archive/v${pkgver}/$pkgname-$pkgver.tar.gz")
sha256sums=('3e464afa77335de200aeb739074a11e96d9bef6d0b519950cfa6684c4be1f350')

build() {
  cmake -S $pkgname-$pkgver -B build -G Ninja \
    -DCMAKE_INSTALL_PREFIX='/usr' \
    -DBUILD_SHARED_LIBS:BOOL=ON \
    -Denable_internal_blaslib:BOOL=OFF \
    -DCMAKE_INSTALL_INCLUDEDIR:PATH=include/superlu/
  cmake --build build
}

check(){
  ctest --test-dir build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -Dm644 $pkgname-$pkgver/DOC/ug.pdf "$pkgdir/usr/share/doc/$pkgname/ug.pdf"
  install -Dm644 $pkgname-$pkgver/License.txt "$pkgdir/usr/share/licenses/$pkgname/License.txt"
}
